package com.longsys.framework.server.mongo;

import com.longsys.eventsourcing.core.EventAggregate;
import com.longsys.eventsourcing.core.EventUser;
import lombok.Data;
import org.bson.types.ObjectId;
import org.springframework.data.annotation.Id;

import java.util.Date;

@Data
public class MongoEventEntity {

    @Id
    private ObjectId _id;

    private String sourcingId;

    private String system;

    private String eventType;

    private String aggregateType;

    private Date eventTime;

    private EventUser eventUser;

    private ObjectId aggregateObjectId;

    public MongoEventEntity() {
    }

    public MongoEventEntity(EventAggregate eventAggregate) {
        this.sourcingId = eventAggregate.getSourcingId();
        this.system = eventAggregate.getSystem();
        this.eventType = eventAggregate.getEventType();
        this.aggregateType = eventAggregate.getAggregateType();
        this.eventTime = eventAggregate.getEventTime();
        this.eventUser = eventAggregate.getEventUser();
        this.aggregateObjectId = eventAggregate.getAggregateObjectId();
    }
}
